<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
#macro ( genericTree $somelist ) 
#foreach ( $some in $somelist )
<option value="$!some.id">#if($!some.level>0)
#foreach($count in [0..$!some.level])&nbsp;&nbsp;#end #end $!some.className</option>
#genericTree($some.childs) 
#end 
#end
<link href="$!webPath/resources/style/system/manage/$!{config.websiteCss}/template.css"  rel="stylesheet" type="text/css"/>
<script src="$!webPath/resources/js/jquery-1.8.3.min.js"></script>
<script src="$!webPath/resources/js/jquery.validate.min.js"></script>
<script src="$!webPath/resources/js/jquery.shop.common.js"></script>
<script src="$!webPath/resources/js/jquery.poshytip.min.js"></script>
<script src="$!webPath/resources/js/vue.min.js"></script>
<script charset="utf-8" src="$!webPath/resources/editor/kindeditor.js"></script>
<script charset="utf-8" src="$!webPath/resources/editor/lang/zh_CN.js"></script>
<script src="$!webPath/resources/layui/layui.all.js"></script>
<script>
//options为编辑配置属性
var options = {
        cssPath : '$!webPath/resources/editor/themes/default/default.css',
        filterMode : true,
		uploadJson:'$!webPath/upload.htm',
		width : '700px',
		height:'400px',
		syncType:"form",
		afterCreate : function() {
							var self = this;
							self.sync();
						},
		afterChange : function() {
							var self = this;
							self.sync();
						},
		afterBlur : function() {
							var self = this;
							self.sync();
						},
		items:['source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
			'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
			'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
			'superscript', '|', 'selectall', 'clearhtml','quickformat','|',
			'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
			'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'link', 'unlink', '|', 'about']
};
jQuery(document).ready(function(){
//设置默认状态以及判断初始显示状态
	var state = jQuery("#display").val();
	if(state==""){
		jQuery("#display").val("true");
		jQuery("#displayOff").hide();
	}else{
		 if(state=="true"){
			jQuery("#displayOff").hide();
		}else{
			jQuery("#displayOn").hide();
		}
	}	
	
  jQuery("#theForm").validate({
    rules:{
    	name:{required :true},
    	accessPath:{required :true},
    	colTemplate:{required :true},
    	phoTemplate:{required :true},
    	orderid:{number:true}
	 },
	messages:{
		name:{required:"栏目名称不能为空"},
		accessPath:{required:"访问路径不能为空"},
		colTemplate:{required:"栏目模板不能为空"},
		phoTemplate:{required:"手机模板不能为空"},
		orderid:{number:"排列顺序不能为空并且为数字"}
	}
  }); 

  editor = KindEditor.create('#content',options); 
  jQuery("#class_id").val("$!obj.articleClass.id");
  //
   jQuery("#display_img").click(function(){
    var display=jQuery("#display").val();
	if(display=="true"){
	  jQuery("#display_img").attr("src","$!webPath/resources/style/system/manage/blue/images/no.jpg");
	  jQuery("#display").val("false");
	}else{
	  jQuery("#display_img").attr("src","$!webPath/resources/style/system/manage/$!{config.websiteCss}/images/yes.jpg");
	  jQuery("#display").val("true");
	}
  }); 
}); 

function saveForm(){
   //debugger;
   var arr=[];
   var remarkSize = jQuery("#rsize").attr("remarkSize");
   for(var i=1;i<=remarkSize;i++){
	    var id=i;
  	    var remarkName=jQuery("#rs"+id).html();
  	    var name = jQuery("#sel"+id).find("option:selected").text();
  	    var remarkValue = "";
  	    jQuery("#rem"+id).find("option:selected").each(function(){
  	    	remarkValue = remarkValue+"，"+jQuery(this).text();
  	    });
  	    remarkValue = remarkValue.substring(1);
  	    var temp = {
	    		"id":id,
	    		"remarkName":remarkName,
	    		"name":name,
	    		"remarkValue":remarkValue
	    }
  	    arr.push(temp);
   }
  
//    jQuery("#class_id11 option:selected").each(function() {
// 	    var a=$(this).attr("value")
// 	    arr.push(a)
// 	});
   var prepareColumn = JSON.stringify(arr);
   //var prepareColumn=arr.join(",");
   jQuery("input[name='prepareColumn']").attr("value",prepareColumn);
   jQuery("#theForm").submit();
}

function getParentLevel(){
	var columnLevel = jQuery("#columnLevel").val();
	if(columnLevel==1){
		jQuery("#parentLevel").html("");
		return false;
	}
	jQuery.ajax({
		url : "$!webPath/admin/parentLevel.htm",
		data : {
			"columnLevel":columnLevel
		},
		type : "POST",
		dataType : "json",
		error : function() {
			return false;
		},
		success : function(data) {
			//debugger;
			jQuery("#parentLevel").html("");
			//each的写法
            jQuery.each(data, function(i, item){     
            	//var node="<option value="+item.id+">"+item.name+"</option>";       
            	jQuery("#parentLevel").append("<option value='"+item.id+"'>"+item.name+"</option>");     
        	});
			 
		}
    });					
}


function getRemark(){
	//debugger;
	var remarkId = jQuery("#remark").val();
	if(remarkId==""){
		return false;
	}
	jQuery.ajax({
		url : "$!webPath/admin/remarkName.htm",
		data : {
			"remarkId":remarkId,
			"method" :"1"
		},
		type : "POST",
		dataType : "json",
		error : function() {
			return false;
		},
		success : function(data) {
			//debugger;
			jQuery("#remarkValue").html("<option value=''>请选择</option>");
			//each的写法
            jQuery.each(data, function(i, item){     
            	jQuery("#remarkValue").append("<option value='"+item.id+"'>"+item.name+"</option>"); 
        	});
			 
		}
    });					
}

function getRemarkValue(){
	var remarkId = jQuery("#remarkValue").val();
	if(remarkId==""){
		return false;
	}
	jQuery.ajax({
		url : "$!webPath/admin/remarkName.htm",
		data : {
			"remarkId":remarkId,
			"method" :"2"
		},
		type : "POST",
		dataType : "json",
		error : function() {
			return false;
		},
		success : function(data) {
			//debugger;
			jQuery("#class_id11").html("");
			//each的写法
            jQuery.each(data, function(i, item){     
            	jQuery("#class_id11").append("<option value='"+item+"'>"+item+"</option>"); 
        	});
			
			 
		}
    });					
}

function chooseIt(){
	if(jQuery("#comb")[0].checked){
		jQuery("#doctitle").removeAttr("disabled");
	}else{
		jQuery("#doctitle").attr("disabled","disabled");
	}
}
function abcd(id){
	//debugger;
	var remark = jQuery("#sel"+id).find("option:selected").attr("remarkvalue");
	var data = remark.split("，");
	jQuery("#rem"+id).html("");
	jQuery.each(data, function(i, item){
    	jQuery("#rem"+id).append("<option value='"+item+"'>"+item+"</option>"); 
	});
	
	
}
</script>
</head>
<body>
<div class="cont" >
  <h1 class="seth1">文章管理</h1>
  <div class="settab"><span class="tab-one"></span> <span class="tabs"> <a href="$!webPath/admin/ezsColumn_list.htm">管理</a> | <a href="$!webPath/admin/loadAddEzsColumn.htm" #if(!$!edit)class="this"#end>新增</a> #if($!edit) <a href="javascript:void(0);" class="this">编辑</a> #end </span> <span class="tab-two"></span></div>
  <form name="theForm" id="theForm" action="$!webPath/admin/addEzsColumn.htm" method="post">
    <input name="prepareColumn" type="hidden" value="" />
    <div class="setcont">
      <ul class="set1">
          <li><span>栏目类别：</span><span class="webnamesec sizese" style="margin-left: 10px">
          <select name="columnLevel" id="columnLevel" onchange="getParentLevel();">
            <option value="1">一级栏目</option>
            <option value="2">二级栏目</option>
            <option value="3">三级栏目</option>
          </select>
          </span>
          <span style="margin-left: 10px">上级栏目：</span><span class="webnamesec sizese" style="margin-left: 10px">
          <select name="parentLevel" id="parentLevel">
<!--             <option value="1">一级栏目</option> -->
<!--             <option value="2">二级栏目</option> -->
<!--             <option value="3">三级栏目</option> -->
          </select>
          </span>
          </li>
          <li>
            <span>栏目属性：</span>
            <span>
              <ul>
                <li @click="pink=1|formatType(1)"><input type="radio" name="attribute" checked="checked" value="1"/>最终列表栏目（允许在本栏目发布文档、并生成文档列表）</li>
                <li @click="pink=2"><input type="radio" name="attribute" value="2"/>频道封面（栏目本身不允许发布文档）</li>
                <li @click="pink=3|formatType(3)"><input type="radio" name="attribute" value="3"/>仅为单独内容页（关于我们、公司简介之类）</li>
                <li @click="pink=4"><input type="radio" name="attribute" value="4"/>外部链接（需要在“访问路径”处填写外链地址）</li>
              </ul>
            </span>
          </li>
          <li v-if="pink==1">
	          <span id="rsize" remarkSize="$!{remarks.size()}">最终栏目列表：</span><span class="webnamesec sizese" style="margin-left: 10px">
	            #foreach($rs in $!remarks)
	              <span id="rs$velocityCount">$rs.name</span> 
	              <select id="sel$velocityCount" onchange="abcd($velocityCount)">
		              #foreach($ca in $!rs.cla) 
		               #if($velocityCount==1) #set($rvs =$!CommUtil.splitByChar($!ca.remarkValue,',') ) #end
		                <option remarkvalue="$!ca.remarkValue">$!ca.name</option> 
		               #end
	              </select>
	              <br/>
	              <span>标签</span> 
	              <select id="rem$velocityCount" multiple="multiple">
	                #foreach($vs in $!rvs)
	                <option>$vs</option>
	                #end
	              </select><br />            
	            #end	            
	       </li>
	             <li><span>栏目名称：</span><span><input type="text" size="40" name="name"/></span></li>
        <li><span>访问路径：</span><span><input type="text" size="40" name="accessPath"/></span></li>
        <li><span>栏目模板：</span><span><input type="text" size="40" name="colTemplate"/></span>
          <span>&nbsp;&nbsp;&nbsp;&nbsp;手机模板：</span><span><input type="text" size="40" name="phoTemplate"/></span>
        </li>
        <li><span>栏目排序：</span><span><input type="text" size="40" name="orderid"/>（由低 -> 高）</span>
        <span>&nbsp;&nbsp;&nbsp;&nbsp;显示：</span><span><input type="radio" size="40" name="reveal" value="true" checked="checked"/>是&nbsp;&nbsp;<input type="radio" size="40" name="reveal" value="false"/>否</span>
        </li>
        <li><span>meta标签：</span><span><input type="text" size="40" name="title"/></span></li>
        <li><span>meta关键字：</span><span><input type="text" size="40" name="keyWord"/></span></li>
        <li><span>meta描述：</span><span><textarea cols="200" rows="10" name="description"></textarea></span></li>
        <li>
            <span>浏览权限：</span>
            <span>
              <ul>
                <li><input type="radio" name="browsePower" value="1" checked="checked"/>所有人</li>
                <li><input type="radio" name="browsePower" value="2"/>注册会员</li>
                <li><input type="radio" name="browsePower" value="3"/>付费会员</li>
              </ul>
            </span>
          </li>
          <li>
            <span>审核权限：</span>
            <span>
              <ul>
                <li><input type="radio" name="review" checked="checked" value="false"/>不需要审核</li>
                <li><input type="radio" name="review" value="true"/>需要审核</li>
              </ul>
            </span>
          </li>
          <li v-if="pink!=1&&pink!=2&&pink!=4"><strong class="orange fontsize20">*</strong>内容</li>
	        <li v-show="pink!=1&&pink!=2&&pink!=4"><span class="webname">
	          <textarea name="content" cols="40" id="content">$!obj.content</textarea>
	          </span></li>
      </ul>
    </div>
  </form>
    <div class="submit">
    <input name="" type="button" value="保存" style="cursor:pointer;" onclick="saveForm();"/>
    </div>
</div>
<script>
var vm=new Vue({
    el:"#theForm",
    data:{
    	pink:1
    },
    mounted:function () {
        this.$nextTick(function () {
            this.init();
        })
    },
    filters:{
    	formatMoney(value){
        }
    },
    methods:{
        init:function (){
        },
        formatType:function(v){
            if(v==3){
            	editor = KindEditor.create('#content',options); 
            	//jQuery("#class_id").val("$!obj.articleClass.id");
            }
        }
    }
});	
 </script>
</body>
</html>
